package com.ruoyi.web.controller.admin;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BdmBindingChange;
import com.ruoyi.system.domain.dto.BdmBindingChangeDto;
import com.ruoyi.system.domain.vo.BdmBindingChangeVo;
import com.ruoyi.system.service.IBdmBindingChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户绑定关系变动Controller
 * 
 * @author ruoyi
 * @date 2024-12-27
 */
@RestController
@RequestMapping("/system/change")
public class BdmBindingChangeController extends BaseController
{
    @Autowired
    private IBdmBindingChangeService bdmBindingChangeService;

    /**
     * 查询用户绑定关系变动列表
     * @return {@link BdmBindingChangeVo}
     */
    @GetMapping("/list")
    public TableDataInfo list(BdmBindingChangeDto bdmBindingChange)
    {
        startPage();
        List<BdmBindingChangeVo> list = bdmBindingChangeService.listVo(bdmBindingChange);
        return getDataTable(list);
    }

    /**
     * 导出用户绑定关系变动列表
     */
    @Log(title = "用户绑定关系变动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BdmBindingChange bdmBindingChange)
    {
        List<BdmBindingChange> list = bdmBindingChangeService.selectBdmBindingChangeList(bdmBindingChange);
        ExcelUtil<BdmBindingChange> util = new ExcelUtil<BdmBindingChange>(BdmBindingChange.class);
        util.exportExcel(response, list, "用户绑定关系变动数据");
    }

    /**
     * 获取用户绑定关系变动详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bdmBindingChangeService.selectBdmBindingChangeById(id));
    }

    /**
     * 新增用户绑定关系变动
     */
    @Log(title = "用户绑定关系变动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BdmBindingChange bdmBindingChange)
    {
        return toAjax(bdmBindingChangeService.insertBdmBindingChange(bdmBindingChange));
    }

    /**
     * 修改用户绑定关系变动
     */
    @Log(title = "用户绑定关系变动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BdmBindingChange bdmBindingChange)
    {
        return toAjax(bdmBindingChangeService.updateBdmBindingChange(bdmBindingChange));
    }

    /**
     * 删除用户绑定关系变动
     */
    @Log(title = "用户绑定关系变动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bdmBindingChangeService.deleteBdmBindingChangeByIds(ids));
    }

    @GetMapping("/listPages")
    public TableDataInfo listPages(BdmBindingChangeDto bdmBindingChange)
    {
        startPage();
        List<BdmBindingChangeVo> list = bdmBindingChangeService.listPage(bdmBindingChange);
        return getDataTable(list);
    }
}
